package lion.framework.core.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lion
 * @date 2017年8月8日
 */
public class RequestContext {

	private HttpServletRequest request;
	private HttpServletResponse response;
	public static ThreadLocal<RequestContext> context = new ThreadLocal<>();

	public RequestContext(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		this.response = response;
	}

	public static void set(HttpServletRequest request, HttpServletResponse response) {
		context.set(new RequestContext(request, response));
	}

	public static void unset() {
		context.set(null);
	}

	public static HttpServletResponse getResponse() {
		RequestContext context1 = context.get();
		return context1.response;
	}

	public static HttpServletRequest getRequest() {
		RequestContext context1 = context.get();
		return context1.request;
	}
}
